<template>
  <div class="main_box" style="padding:10px">
    <div class="add_wrap">
      <el-form label-width="200px" v-if="dataInfo">
        <div class="tit">
          <h2>基础信息</h2>
          <el-button
            type="success"
            plain
            size="small"
            icon="fa fa-mail-forward"
            @click="returnList"
            >返回</el-button
          >
        </div>
        <el-row>
          <el-form-item label="报警编号:">
            <span>{{ dataInfo.alarmNo }}</span>
          </el-form-item>
          <el-form-item label="报警类型:">
            <span>{{ dataInfo.alarmType }}</span>
          </el-form-item>

          <el-form-item label="报警来源:">
            <span>{{ dataInfo.alarmSource==1?'呼叫器设备':'' }}</span>
          </el-form-item>
        
          <el-form-item label="呼叫器编号:">
            <span
              >{{ dataInfo.beeperCode }}</span
            >
          </el-form-item>
          <el-form-item label="呼叫器联系人:">
            <span
              >{{ dataInfo.linkName }}</span
            >
          </el-form-item>
          <el-form-item label="呼叫器联系电话:">
            <span
              >{{ dataInfo.phone }}</span
            >
          </el-form-item>
          <el-form-item label="小区物业名称:">
            <span
              >{{ dataInfo.pmcName }}</span
            >
          </el-form-item>
          <el-form-item label="小区物业电话:">
            <span
              >{{ dataInfo.pmcPhone }}</span
            >
          </el-form-item>
          <el-form-item label="小区物业备用电话:">
            <span
              >{{ dataInfo.pmcPhoneTwo }}</span
            >
          </el-form-item>
          <el-form-item label="通道入口地址:">
            <span
              >{{ dataInfo.exitAddress }}</span
            >
          </el-form-item>
          <el-form-item label="通道入口图:">
            <el-image
              v-if="dataInfo.exitPicture"
              style="width: 200px; height: 200px"
              :src="dataInfo.exitPicture || ''"
              fit="contain"
              :preview-src-list="[dataInfo.exitPicture]"
            >
            </el-image>
          </el-form-item>
          <el-form-item label="通道入口经度:">
            <span
              >{{ dataInfo.exitLng }}</span
            >
          </el-form-item>
          <el-form-item label="通道入口纬度:">
            <span
              >{{ dataInfo.exitLat }}</span
            >
          </el-form-item>
          <el-form-item label="报警设备Id:">
            <span
              >{{ dataInfo.alarmEquipId }}</span
            >
          </el-form-item>
          <el-form-item label="设备报警时的定位地址:">
            <span
              >{{ dataInfo.site }}</span
            >
          </el-form-item>
          <el-form-item label="预计到达时间:">
            <span
              >{{ dataInfo.expectedTime }}</span
            >
          </el-form-item>
          <el-form-item label="状态:">
            <span
              >{{ dataInfo.state==1?'启用':dataInfo.state==0?'禁用':'删除' }}</span
            >
          </el-form-item>
          <el-form-item label="报警人名称:">
            <span
              >{{ dataInfo.createUserName }}</span
            >
          </el-form-item>
          <el-form-item label="报警时间:">
            <span
              >{{ dataInfo.createDate }}</span
            >
          </el-form-item>
          <el-form-item label="是否拨打报警电话:">
            <span>{{ dataInfo.callState==1?'已拨打':'未拨打' }}</span>
          </el-form-item>
          
          <el-form-item label="报警状态:">
            <span>{{ dataInfo.alarmState | statusFilters }}</span>
          </el-form-item>

          <el-form-item label="报警来源:">
            <span>{{ dataInfo.alarmSource | alarmSourceFilters }}</span>
          </el-form-item>
         
          <el-form-item label="报警地址:">
            <span>
              {{ dataInfo.provinceName }} - {{ dataInfo.cityName }} -
              {{ dataInfo.areaName }} - {{ dataInfo.streetName }} -
              {{ dataInfo.villageName }} - {{ dataInfo.buildName }} -
              {{ dataInfo.unitName }} - {{ dataInfo.floorName }} -
              {{ dataInfo.houseNumber }}</span
            >
          </el-form-item>
          <el-form-item label="修改人名称:">
            <span
              >{{ dataInfo.modifyUserName }}</span
            >
          </el-form-item>
          <el-form-item label="修改时间:">
            <span
              >{{ dataInfo.modifyDate }}</span
            >
          </el-form-item>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import alarmApi from "@/api/message/alarm";
export default {
  data() {
    return {
      dataInfo: {},
      alarmId: this.$route.query.alarmId,
      loading: false,
   
    };
  },
  computed: {},
  mounted() {
    this.getData();
  },
  methods: {
 
    getData() {
      this.$emit("show-loading", true);
      alarmApi
        .alarmDetail({ id: this.alarmId})
        .then((res) => {
          this.dataInfo = res.data;
          this.$emit("show-loading", false);
        })
        .catch((error) => {
          this.$emit("show-loading", false);
        });
    },
    returnList() {
      this.$store.dispatch("delView", this.$route);
      this.$router.back();
    },
  },
  filters: {
    statusFilters(val) {
      switch (val) {
        case 1:
          val = "待出警";
          break;
        case 5:
          val = "已出警";
          break;
        case 15:
          val = "已取消";
          break;
        case 16:
          val = "取消失败";
          break;
        case 20:
          val = "已完成";
          break;
      }
      return val;
    },
    alarmSourceFilters(val){
      switch (val) {
        case 1:
          val = "呼叫器";
          break;
        case 2:
          val = "小程序";
          break;
      }
      return val;
    }
  },
};
</script>

<style lang="scss">
@import "@/assets/css/views/content.scss";
@import "@/assets/css/views/add.scss";
</style>
